<template>
  <div id="reservation_details">
        <div class="gbd-shopping-cart-gotobuy"  v-if="type=='doctor'">
                        <router-link :to="{name: 'selectClinic',query: {user:'order',id:this.id,pid:this.pid}}" style="color:#fff">
                立即下单
                        </router-link>
        </div>
    <header>
      <span @click="goBack()">返回</span>
      <div>预约详情</div>
      <span @click='edit'>编辑</span>
    </header>
    <div>
      <ul>
        <li>
          <span>姓名</span>
          <i>{{infoObj.name}}</i>
        </li>
        <li>
          <span>就诊时间</span>
          <i>{{obj.time}}</i>
        </li>
        <li>
          <span>项目</span>
          <span class='flex'>{{obj.project}}</span>
        </li>
        <li class='noBack remarks'>
          <span>备注:</span>
          <textarea placeholder="暂无备注" disabled v-model='obj.remarks'>

            </textarea>
        </li>
      </ul>
    </div>
  

  </div>
</template>
<script>
  export default {
    data() {
      return {
        type: "",
        id: '', //预约记录id
        obj: { //预约记录对象
          pid: '',
        },
        infoObj: {},
        patientObj: {}, //患者对象
        startDate: new Date(),
        isDuration: false, //是否显示时长选择器
        values: '', //就诊时长选择但未确定时的选项
        slots: [{
          values: ['30分钟', '1小时', '1.5小时'],
          className: 'slot1',
          textAlign: 'right'
        }, ],
        isOpenA: true,
        isOpenB: false,
      }
    },
    // watch: {
    //   obj: {
    //     handler(val, oldVal) {
    //     //   this.getPatient(val.pid);
    //     },
    //     deep: true
    //   }
    // },
    methods: {
      //返回上一级
      goBack() {
        // this.$router.back();
        if (localStorage.getItem('type') == '"doctor"') {

          this.$router.push({
            name: "patientDetails",
            query: {
              pid: this.pid
            }
          });
        } else {
          this.$router.push({
            name: "reservation_record",
            query: {
              pid: this.pid
            }
          });
        }

      },
      //获取预约详情
      getDetailsData() {
        this.id = this.$route.query.id; //预约的id
        // this.obj.pid = this.$route.query.pid;
        this.$api.get(this.$api.baseURLSchool, "select_cid/appointment/" + this.id, {}, r => {
          if (r.data.ret == 1) {
            this.obj = r.data.info;
          }
        }, err => {
          console.log(err);
        })
      },
      //获取患者详情
      getDetails() {
        this.pid = this.$route.query.pid;
        this.$api.get(this.$api.baseURLSchool, "select_cid/patient/" + this.pid, {}, r => {
          if (r.data.ret == 1) {
            this.infoObj = r.data.info;
          }
        }, err => {
          console.log(err);
        })
      },
      //编辑预约
      edit() {
        this.$router.push({
          name: 'addNewAppointment',
          query: {
            from: 'reservation_details',
            id: this.id,
            status: 'edit',
            pid: this.pid
          }
        });
      }
    },
    created() {
      this.type = JSON.parse(localStorage.getItem('type'));
      this.getDetailsData();
      this.getDetails();

    },
  }

</script>
<style lang="scss" scoped>
  

</style>
